<template>
<div class="product-add">
    <!--form表单-->
    <el-form ref="form" :model="form" label-width="250px">
      <!--添加门店-->
      <div class="common-form">{{$t('setting.miniapp_settings')}}</div>
      <el-form-item :label="$t('setting.miniapp_appid')">
        <el-input v-model="form.wxapp_id"></el-input>
      </el-form-item>
      <el-form-item :label="$t('setting.miniapp_secret')">
        <el-input v-model="form.wxapp_secret" type="password"></el-input>
      </el-form-item>


      <div class="common-form">{{$t('setting.wechatpay_settings')}}</div>

      <el-form-item :label="$t('setting.wechatpay_mchid')">
        <el-input v-model="form.mchid"></el-input>
      </el-form-item>
      <el-form-item :label="$t('setting.wechatpay_apikey')">
        <el-input v-model="form.apikey"></el-input>
      </el-form-item>

      <el-form-item label="apiclient_cert.pem">
        <el-input type="textarea" :rows="4" :placeholder="$t('setting.cert_pem_instruction')" v-model="form.cert_pem"></el-input>
        <div class="tips">{{$t('setting.key_pem_instruction')}}</div>
      </el-form-item>
      <el-form-item label="apiclient_key.pem">
        <el-input type="textarea" :rows="4" :placeholder="$t('setting.cert_pem_instruction')" v-model="form.key_pem"></el-input>
        <div class="tips">{{$t('setting.key_pem_instruction')}}</div>
      </el-form-item>

      <!--提交-->
      <div class="common-button-wrapper">
          <el-button type="primary" @click="onSubmit">{{$t('setting.submit_button')}}</el-button>
      </div>
    </el-form>


  </div>
</template>

<script>
import SettingApi from '@/api/setting.js';
export default {
  data() {
    return {
      /*切换菜单*/
      // activeIndex: '1',
      /*form表单数据*/
      form: {}
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      let self = this;
      SettingApi.wxappDetail({}, true).then(data => {
        self.form = data.data.data;
      }).catch(error => {});
    },
    //提交表单
    onSubmit() {
      let self = this;
      let params = this.form;
      SettingApi.editWxapp(params, true).then(data => {
        ElMessage({
          message: $t("setting.setting_success"),
          type: 'success'
        });
        self.$router.push('/setting/wxapp');
      }).catch(error => {});
    }
  }
};
</script>

<style>
.tips {
    color: #ccc;
  }
</style>

